package game;

import javax.swing.*;
import java.awt.*;
import java.util.Random;
//敌人对象
public class Enemy {

    private int x;//敌机坐标
    private int y;
    private int height;//敌人图片的高度
    private int width;//敌人图片的宽度
    private ImageIcon enemyImageIcon = new ImageIcon("img/enemy.png");

    public Enemy() {//构造器
        height = enemyImageIcon.getIconHeight();
        width = enemyImageIcon.getIconWidth();

        Random random = new Random();//设置敌机的位置（随机）
        x = random.nextInt(GameMain.width - width);
        y = -random.nextInt(GameMain.height - height);//从上往下
    }

    public void move() {//速度
        y +=1;
    }

    public void drawImage(Graphics g) {
        g.drawImage(enemyImageIcon.getImage(), x, y, null);
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public ImageIcon getEnemyImageIcon() {
        return enemyImageIcon;
    }

    public void setEnemyImageIcon(ImageIcon enemyImageIcon) {
        this.enemyImageIcon = enemyImageIcon;
    }

}